
<template>
    <div>
        <el-dialog
                :title="title"
                :close-on-click-modal="false"
                v-dialogDrag
                :visible.sync="editVisible"
        >
            <el-form
                    v-loading="loading"
                    label-width="105px"
                    ref="editForm"
                    :model="editForm">

                                            <el-form-item label="账务处理类型:" prop="accountDealType" :rules="[
                              {required: true, message:'请输入账务处理类型', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.accountDealType"></el-input>
                            </el-form-item>
                            <el-form-item label="往来ID:" prop="companyId" :rules="[
                              {required: true, message:'请输入往来ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.companyId"></el-input>
                            </el-form-item>
                            <el-form-item label="往来账户ID:" prop="companyAccountId" :rules="[
                              {required: true, message:'请输入往来账户ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.companyAccountId"></el-input>
                            </el-form-item>
                            <el-form-item label="业务ID:" prop="businessId" :rules="[
                              {required: true, message:'请输入业务ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.businessId"></el-input>
                            </el-form-item>
                            <el-form-item label="转入往来ID:" prop="toCompanyId" :rules="[
                              {required: true, message:'请输入转入往来ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.toCompanyId"></el-input>
                            </el-form-item>
                            <el-form-item label="转入往来账户ID:" prop="toCompanyAccountId" :rules="[
                              {required: true, message:'请输入转入往来账户ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.toCompanyAccountId"></el-input>
                            </el-form-item>
                            <el-form-item label="通知金额:" prop="noticeMoney" :rules="[
                              {required: true, message:'请输入通知金额', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.noticeMoney"></el-input>
                            </el-form-item>
                            <el-form-item label="使用活动余额:" prop="activityMoneyUsed" :rules="[
                              {required: true, message:'请输入使用活动余额', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.activityMoneyUsed"></el-input>
                            </el-form-item>
                            <el-form-item label="实际收款金额:" prop="actualMoney" :rules="[
                              {required: true, message:'请输入实际收款金额', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.actualMoney"></el-input>
                            </el-form-item>
                            <el-form-item label="金额系数:" prop="ratio" :rules="[
                              {required: true, message:'请输入金额系数', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.ratio"></el-input>
                            </el-form-item>
                            <el-form-item label="通知编号:" prop="notificationCode" :rules="[
                              {required: true, message:'请输入通知编号', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.notificationCode"></el-input>
                            </el-form-item>
                            <el-form-item label="通知人ID:" prop="noticePeopleId" :rules="[
                              {required: true, message:'请输入通知人ID', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.noticePeopleId"></el-input>
                            </el-form-item>
                            <el-form-item label="通知人:" prop="noticePeople" :rules="[
                              {required: true, message:'请输入通知人', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.noticePeople"></el-input>
                            </el-form-item>
                            <el-form-item label="通知时间:" prop="noticeTime" :rules="[
                              {required: true, message:'请输入通知时间', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.noticeTime"></el-input>
                            </el-form-item>

                            <el-form-item label="收款时间:" prop="receiveTime" :rules="[
                              {required: true, message:'请输入收款时间', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.receiveTime"></el-input>
                            </el-form-item>
                            <el-form-item label="状态:" prop="state" :rules="[
                              {required: true, message:'请输入状态', trigger:'blur'}
                             ]">
                                <el-input v-model="editForm.state"></el-input>
                            </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
        <div class="footer-input">
          <el-button size="small" type="primary" @click="doSubmit()" v-noMoreClick
          >确定</el-button
          >
        <el-button size="small" @click="close()">取消</el-button>

        </div>

      </span>
        </el-dialog>
    </div>
</template>
<script>
    import {save, getById} from '@/api/finance/FinanceReceive.js';
    export default {
        components: {
        },
        data () {
            return {
                loading: false,
                areaLabel: {},
                method: '',
                title: '',
                editForm: {
                            id: '',
                            accountDealType: '',
                            companyId: '',
                            companyAccountId: '',
                            businessId: '',
                            toCompanyId: '',
                            toCompanyAccountId: '',
                            noticeMoney: '',
                            activityMoneyUsed: '',
                            actualMoney: '',
                            ratio: '',
                            notificationCode: '',
                            noticePeopleId: '',
                            noticePeople: '',
                            noticeTime: '',
                            receivePeopleId: '',
                            receivePeople: '',
                            receiveTime: '',
                            state: ''
                },
                editVisible: false,
                detailsVisible: false,
                tableData1: [],
                page: {
                    pageSize: 10,
                    pageNo: 1,
                    total: 0
                },
                props: 1,
                dialogVisible: false,
                query: ''
            }
        },
        methods: {
	        	handleClose(done) {
							this.$Msg.confirm({
								title:'您确定要关闭吗？',
								content:this.GLOBAL.FORM_CLOSE_TIPS,
								confirmCall:()=>{
									done();
								}
							})
						},
            select (e) {
                this.editForm.companyName = e.names
                this.editForm.companyId = e.id
                this.dialogVisible = false
                console.log(e)
            },
            init (method, obj) {
                if (method === 'add') {
                    this.editVisible = true
                    this.$nextTick(() => {
                        this.$refs.editForm.resetFields()
                        // this.editForm = {}
                    })
                            this.editForm.id = ''
                            this.editForm.accountDealType = ''
                            this.editForm.companyId = ''
                            this.editForm.companyAccountId = ''
                            this.editForm.businessId = ''
                            this.editForm.toCompanyId = ''
                            this.editForm.toCompanyAccountId = ''
                            this.editForm.noticeMoney = ''
                            this.editForm.activityMoneyUsed = ''
                            this.editForm.actualMoney = ''
                            this.editForm.ratio = ''
                            this.editForm.notificationCode = ''
                            this.editForm.noticePeopleId = ''
                            this.editForm.noticePeople = ''
                            this.editForm.noticeTime = ''
                            this.editForm.receivePeopleId = ''
                            this.editForm.receivePeople = ''
                            this.editForm.receiveTime = ''
                            this.editForm.state = ''
                    this.title = '新增'
                    this.visible = true
                    this.loading = false
                } else if (method === 'edit') {
                    this.editVisible = true
                    this.method = method
                    this.title = '修改'
                    console.log(obj.id)
                    this.$set(this.editForm, 'id', obj.id);
                    this.$nextTick(() => {
                        this.loading = true
                        if (method === 'edit' || method === 'view') { // 修改或者查看
                            getById({id: this.editForm.id}).then((res) => {
                                if (res.data.code === '200') {
                                    this.editForm = res.data.result
                                    this.loading = false
                                } else {
                                    this.loading = false
                                    this.visible = false
                                    this.$message({
                                        type: 'error',
                                        message: res.data.message
                                    })
                                }
                            })
                        }
                    })
                    this.visible = true
                    this.loading = false
                }

            },
            close () {
                this.editVisible = false
            },
            doSubmit () {
                this.$refs['editForm'].validate((valid) => {
                    if (valid) {
                        save(this.editForm).then((res) => {
                            if (res.data.code === '200') {
                                this.$message({
                                    message: '编辑成功',
                                    type: 'success'
                                })
                                this.editVisible = false
                                this.$emit('refreshDataList')
                            }
                        })
                    }
                })
            }
        },
        mounted () {

        }
    }
</script>
<style lang="scss" scoped>
    ::v-deep .el-dialog{
    .el-form{
    .el-input__inner{
        width: 320px;
    }
    .inputAppend-wrapper{
    .el-input__inner{
        width: 282px;
    }
    }
    }
    }
</style>
